home *** CD-ROM | disk | FTP | other *** search
- head 1.2;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @@;
-
-
- 1.2
- date 90.05.01.22.57.20; author shirriff; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 90.03.15.12.32.04; author shirriff; state Exp;
- branches ;
- next ;
-
-
- desc
- @Original Unix man page.
- @
-
-
- 1.2
- log
- @Made changes to the man page.
- @
- text
- @.\" @@(#)semctl.2 1.18 88/03/07 SMI; from S5R3
- .TH SEMCTL 2 "21 November 1987"
- .SH NAME
- semctl \- semaphore control operations
- .SH SYNOPSIS
- .nf
- .ft B
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/sem.h>
- .LP
- .ft B
- int semctl (semid, semnum, cmd, arg)
- int semid, cmd;
- int semnum;
- union semun {
- val;
- struct semid_ds \(**buf;
- ushort \(**array;
- } arg;
- .ft R
- .fi
- .SH DESCRIPTION
- .IX semctl "" "\fLsemctl\fR \(em semaphore controls"
- .IX semaphore "control \(em \fLsemctl\fR"
- .B semctl(\|)
- provides a variety of semaphore control operations as specified by
- .IR cmd .
- .LP
- The following
- .IR cmd s
- are executed with respect to the semaphore specified by
- .IR semid " and " semnum:
- .RS
- .TP 20
- .B GETVAL
- Return the value of
- .I semval
- (see
- .BR intro (2)).
- .B {\s-1READ\s0}
- .TP
- .B SETVAL
- Set the value of
- .I semval
- to
- .IR arg.val .
- .B {\s-1ALTER\s0}
- .TP
- .B GETPID
- Return the value of
- .IR sempid .
- .B {\s-1READ\s0}
- .TP
- .B GETNCNT
- Return the value of
- .IR semncnt .
- .B {\s-1READ\s0}
- .TP
- .B GETZCNT
- Return the value of
- .IR semzcnt .
- .B {\s-1READ\s0}
- .RE
- .LP
- The following
- .IR cmd s
- return and set, respectively, every
- .I semval
- in the set of semaphores.
- .RS
- .TP
- .B GETKEYS
- Place the partial contents of all semaphore
- entries into the array pointed to by
- .I arg.buf .
- .TP
- .B GETALL
- Place
- .I semvals
- into the array pointed to by
- .IR arg.array .
- .B {\s-1READ\s0}
- .TP
- .B SETALL
- Set
- .I semvals
- according to the array pointed to by
- .IR arg.array .
- .B {\s-1ALTER\s0}
- .RE
- .LP
- The following
- .IR cmd s
- are also available:
- .RS
- .TP 20
- .B IPC_STAT
- Place the current value of each member of the data structure associated with
- .I semid
- into the structure pointed to by
- .IR arg.buf .
- The contents of this structure are defined in
- .BR intro (2).
- .B {\s-1READ\s0}
- .TP
- .B IPC_SET
- Set the value of the following members of the data structure associated with
- .I semid
- to the corresponding value found in the structure pointed to by
- .IR arg.buf :
- .IP
- .nf
- .B sem_perm.uid
- .B sem_perm.gid
- .B "sem_perm.mode /\(** only low 9 bits \(**/"
- .fi
- .IP
- This
- .I cmd
- can only be executed by a process that has an effective user
- .SM ID
- equal to either that of super-user, or to the value of
- .B sem_perm.cuid
- or
- .B sem_perm.uid
- in the data structure associated with
- .IR semid .
- .br
- .ne 5
- .TP 20
- .B IPC_RMID
- Remove the semaphore identifier specified by
- .I semid
- from the system and destroy the set of semaphores and data structure
- associated with it.
- This cmd can only be executed by a process that has an effective user
- .SM ID
- equal to either that of super-user, or to the value of
- .B sem_perm.cuid
- or
- .B sem_perm.uid
- in the data structure associated with
- .IR semid .
- .RE
- .SH "RETURN VALUE"
- .LP
- Upon successful completion,
- the value returned depends on
- .I cmd
- as follows:
- .PD 0
- .RS
- .TP 20
- .B GETVAL
- The value of
- .IR semval .
- .TP
- .B GETPID
- The value of
- .IR sempid .
- .TP
- .B GETNCNT
- The value of
- .IR semncnt .
- .TP
- .B GETZCNT
- The value of
- .IR semzcnt .
- .TP
- All others
- A value of 0.
- .RE
- .LP
- .PD
- Otherwise, a value of \-1 is returned and
- .B errno
- is set to indicate the error.
- .SH ERRORS
- .B semctl(\|)
- will fail if one or more of the following are true:
- .TP 20
- .SM EINVAL
- .I semid
- is not a valid semaphore identifier.
- .TP
- .SM EINVAL
- .I semnum
- is less than zero or greater than
- .BR sem_nsems .
- .TP
- .SM EINVAL
- .I cmd
- is not a valid command.
- .TP
- .SM EACCES
- Operation permission is denied to the calling process (see
- .BR intro (2)).
- .TP
- .SM ERANGE
- .I cmd
- is
- .B SETVAL
- or
- .B SETALL
- and the value to which
- .I semval
- is to be set is greater than the system imposed maximum.
- .TP
- .SM EPERM
- .I cmd
- is equal to
- .B IPC_RMID
- or
- .B IPC_SET
- and the effective user
- .SM ID
- of the calling process is not equal to that of super-user, or
- to the value of
- .B sem_perm.cuid
- or
- .B sem_perm.uid
- in the data structure associated with
- .IR semid .
- .TP
- .SM EFAULT
- .I arg.buf
- points to an illegal address.
- .SH SEE ALSO
- .BR intro (2),
- .BR semget (2),
- .BR semop (2).
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d36 1
- a36 1
- .SB GETVAL
- d43 1
- a43 1
- .SB SETVAL
- a48 4
- When this cmd is successfully executed, the
- .I semadj
- value corresponding to the
- specified semaphore in all processes is cleared.
- d50 1
- a50 1
- .SB GETPID
- d55 1
- a55 1
- .SB GETNCNT
- d60 1
- a60 1
- .SB GETZCNT
- d73 6
- a78 1
- .SB GETALL
- d85 1
- a85 1
- .SB SETALL
- a90 4
- When this cmd is successfully executed the
- .I semadj
- values corresponding to each
- specified semaphore in all processes are cleared.
- d98 1
- a98 1
- .SB IPC_STAT
- d107 1
- a107 1
- .SB IPC_SET
- d132 1
- a132 1
- .SB IPC_RMID
- d155 1
- a155 1
- .SB GETVAL
- d159 1
- a159 1
- .SB GETPID
- d163 1
- a163 1
- .SB GETNCNT
- d167 1
- a167 1
- .SB GETZCNT
- d203 1
- a203 1
- .SB SETVAL
- d205 1
- a205 1
- .SB SETALL
- d213 1
- a213 1
- .SB IPC_RMID
- d215 1
- a215 1
- .SB IPC_SET
- @
-